<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function fnArmy() {
        const arr = [];
        let i = 1;
        while (i <= 5) {
          let j = i;
          arr.push(function () {
            console.log(j);
          });
          i++;
        }

        return arr;
      }

      const fns = fnArmy();
      fns[0]();
      fns[1]();
      fns[2]();
      // console.log(fns);
    </script>
  </body>
</html>
